home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / By the Book / Learn C++ (CodeWarrior) / Chap 09.05 - init / init.cp < prev    next >
Text File  |  1995-10-21  |  566b  |  38 lines

  1. #include <iostream.h>
  2.  
  3.  
  4. //---------------------------------------  MyClass
  5.  
  6. class MyClass
  7. {
  8.     public:
  9.         const short        kMaxNameLength;
  10.         short            &numberAlias;
  11.         short            number;
  12.  
  13.         MyClass( short    constValue );
  14. };
  15.  
  16. MyClass::MyClass( short constValue )
  17.     : kMaxNameLength( constValue ), numberAlias( number )
  18. {
  19.     number = kMaxNameLength;
  20.         
  21.     cout << "Before: number = "
  22.         << number << "\n";
  23.     
  24.     numberAlias += 10;
  25.         
  26.     cout << "After:  number = "
  27.         << number << "\n";
  28. }
  29.  
  30.  
  31. //---------------------------------------  main()
  32.  
  33. int    main()
  34. {
  35.     MyClass        myObject( 10 );
  36.     
  37.     return 0;
  38. }